-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to lock mouse cursor on rotate/grab pan #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the PR! Bevy has built-in cursor lock, so we should use that instead of manually storing and setting the cursor position. See https://bevy-cheatbook.github.io/window/mouse-grab.html
Do you think they should be enabled by default?
I think they should remain false by default.
This actually doesn't work. Perhaps your cursor locking is messing with Screen.Recording.2024-04-29.at.19.55.06.mov |
b2b39b6
to
4dd3bf7
Compare
That's the intended behavior, the mouse cursor stays in place. |
4dd3bf7
to
01cf4f8
Compare
If you watch the video, you can see the camera actually barely moves, but I'm trying to move it. It's stuck, can't rotate it and can't drag it. Maybe this is OS dependent. |
Note: what I suspect is happening is that manually moving the cursor back to where it started actually triggers MouseMotion events, thus also moving the camera back to where it started. If that's the case, you'll have to find an alternative solution. |
01cf4f8
to
f4fb1b9
Compare
I think we can use bevy's built-in |
Sounds good to me |
@Plonq is there anything missing for this PR to be merged? |
Apologies! I didn't realise you'd already made that change. |
This PR introduces two new variables:
lock_on_rotate
andlock_on_drag
. They are meant to allow the mouse cursor to stay in place while rotating/dragging. The cursor is hidden when performing such actions (soCursorGrabMode::Locked
works fine on Windows and Linux).I've set the default to
false
for bothlock_on_rotate
andlock_on_drag
variables andtrue
. Do you think they should be enabled by default?